<template>
  <div id="fish_contanier">
    <router-view/>
  </div>
</template>

<script>
  import '@/assets/css/base.css';
  // import '@/assets/js/e_fish.js';
  const wx = require("weixin-js-sdk");
  import {mapActions} from "vuex";
  import axios from 'axios';
  export default {
    name: 'App',
    mounted() {
      this.$nextTick(() => {
        this.getShareInfo({
          url: location.href.split('#')[0],
          callback: res => {
            wx.config({
              debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
              appId: res.data.appId, // 必填，公众号的唯一标识
              timestamp: res.data.timestamp, // 必填，生成签名的时间戳
              nonceStr: res.data.nonceStr, // 必填，生成签名的随机串
              signature: res.data.signature, // 必填，签名
              jsApiList: [
                "updateAppMessageShareData",
                "updateTimelineShareData",
                "onMenuShareAppMessage",
                "onMenuShareTimeline",
              ]
            });
            wx.ready(() => {
              const option = {
                title: '免费车票开抢啦！',
                desc: '一起搭乘2020年“凯翼号”川籍农民工春节专列回家过年',
                link: 'http://zhiyang.yizehd.com/qiangpiao/',
                imgUrl: 'http://zhiyang.yizehd.com/static/shareimg/qiangpiao.jpg',
              }
              // 微信分享给朋友
              wx.updateAppMessageShareData({
                title: option.title,
                link: option.link,
                imgUrl: option.imgUrl,
                desc: option.desc,
                success() {
                },
                cancel() {
                  // 用户取消分享后执行的回调函数
                }, fail() {
                  // alert("分享失败！"+JSON.stringify(s));
                }
              })
              wx.onMenuShareAppMessage({
                title: option.title,
                link: option.link,
                imgUrl: option.imgUrl,
                desc: option.desc,
                success() {
                },
                cancel() {
                  // 用户取消分享后执行的回调函数
                }, fail() {
                  // alert("分享失败！"+JSON.stringify(s));
                }
              })
              // 微信分享到朋友圈
              wx.updateTimelineShareData({
                title: option.title,
                link: option.link,
                imgUrl: option.imgUrl,
                desc: option.desc,
                success() {
                },
                cancel() {
                }, fail() {
                }
              })
              wx.onMenuShareTimeline({
                title: option.title,
                link: option.link,
                imgUrl: option.imgUrl,
                desc: option.desc,
                success() {
                },
                cancel() {
                }, fail() {
                }
              })
            })
          }
        });
      })

    },
    methods: {
      ...mapActions({
        getShareInfo: "fishH5/getShareInfo",
        // saveTicketInfo: "fishH5/saveTicketInfo",
        getTicketInfo: 'fishH5/getTicketInfo',
      }),
      shouquan() {
        const index_url = 'http://zhiyang.yizehd.com/zhuli'
        window.localStorage.removeItem('token')
        // window.location.href = 'http://zhiyang.yizehd.com/api/auth/auth?state=1&uri=' + index_url;
        window.open('http://zhiyang.yizehd.com/api/auth/auth?state=1&uri=' + index_url)
        return

      },
      getQueryString(name) {
        let reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
        let r = window.location.search.substr(1).match(reg);
        if (r != null) {
          return unescape(r[2]);
        }
        return null;
      },
      show() {
      },
      getZhuli() {
        axios.get('/api/user/getZhuli',{
          params:{td:88}
        }).then(()=>{
          console.log('then')
        }).catch(() => {
          console.log('catch')
        })
      },
    }
  }
</script>
